# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libao
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.2.2
pkgrel=1
pkgdesc="Cross-platform audio output library and plugins (mingw-w64)"
arch=('any')
url="https://xiph.org/ao/"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "git")
license=('GPL')
source=("git+https://git.xiph.org/libao.git#commit=3f4b02f046550aca54d7f11a5d9c56ac421f0b66")
sha256sums=('SKIP')

prepare() {
  cd "${srcdir}"/${_realname}
  ./autogen.sh
}

build() {
  cd "${srcdir}"/${_realname}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  LIBS+="-lksuser -lwinmm" ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --disable-pulse \
    --enable-wmm

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
